package com.ourteam.workspace.api;

import org.apache.commons.lang.StringUtils;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.workspace.dao.WorkspaceServerDAOQueryBean;
import com.ourteam.workspace.domain.WorkspaceServerBean;

public class WorkspaceServerSearchModel extends AbstractSearchModel<WorkspaceServerDAOQueryBean> {

	private String serverName;

	private String serverType;

	@Override
	public String getMappedDAOField(String aProperty) {
		return WorkspaceServerBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(WorkspaceServerDAOQueryBean queryBean) throws Exception {

		WorkspaceServerDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		if (StringUtils.isNotBlank(serverName)) {
			criteria.andServerNameLike(serverName);
		}

		if (StringUtils.isNotBlank(serverType)) {
			criteria.andServerTypeEqualTo(serverType);
		}
	}

	public String getServerName() {
		return serverName;
	}

	public void setServerName(String serverName) {
		this.serverName = serverName;
	}

	public String getServerType() {
		return serverType;
	}

	public void setServerType(String serverType) {
		this.serverType = serverType;
	}

}
